import { fetchGoodLists } from "../../utlis/api"
export default{
    namespaced:true,
    state:{
        cache:{}
    },
    getters:{

    },
    mutations:{
        updateCache(state,payload){
            state.cache[payload.idx]=payload.arr
            //深复制(拷贝)
            state.cache=JSON.parse(JSON.stringify(state.cache))
        },
        clearCache(state){
            state.cache={}
        }

    },
    actions:{
        getCache(store,payload){
            console.log(payload);
            fetchGoodLists({cate:payload.cate}).then(res=>{
                console.log(res);
                store.commit('updateCache', {
                    idx: payload.idx,
                    arr: res.list
                })
            })
        }
    }
}